home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.002.BusyBox / busybox.c / umenu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-19  |  2.0 KB  |  93 lines  |  [TEXT/MPS ]

  1. /***********************************************************************
  2. *
  3. * busybox umenu.c -- Version 3.0
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * This file contains the code which implements
  10. * menus in the busybox program.
  11. *
  12. ***********************************************************************/
  13.  
  14. #include <types.h>
  15. #include <quickdraw.h>
  16. #include <window.h>
  17. #include <event.h>
  18. #include <menu.h>
  19. #include <desk.h>
  20. #include <intmath.h>
  21.  
  22. #include "busybox.h"
  23.  
  24. extern WmTaskRec        event;
  25. extern unsigned int     quitFlag;
  26.  
  27. /**********************************************************************/
  28.  
  29. void    doQuitItem()
  30. {
  31.     quitFlag++;
  32. }
  33.  
  34. /**********************************************************************/
  35.  
  36. void    doAboutItem()
  37. {
  38.     AlertWindow(4, NULL, 0x0001L);
  39. }
  40.  
  41. /**********************************************************************/
  42.  
  43. void    doMenu()
  44. {
  45.     unsigned int    menuNum, itemNum;
  46.  
  47.     /* Procedure to handle all menu selections.  Examines the event.TaskData
  48.     ** menu item ID word from TaskMaster (from Event Manager) and calls the
  49.     ** appropriate routine.  While the routine is running the menu title is
  50.     ** still highlighted.  After the routine returns, we unhilight the
  51.     ** menu title.
  52.     */
  53.  
  54.     menuNum = HiWord(event.wmTaskData);
  55.     itemNum = LoWord(event.wmTaskData);
  56.  
  57.     switch (itemNum) {
  58.         case AboutItem:
  59.             doAboutItem();
  60.             break;
  61.         case CloseItem:
  62.             doCloseTop();
  63.             break;
  64.         case QuitItem:
  65.             doQuitItem();
  66.             break;
  67.         case UndoItem:
  68.         case CutItem:
  69.         case CopyItem:
  70.         case PasteItem:
  71.         case ClearItem:
  72.             break;
  73.     }
  74.  
  75.     HiliteMenu(0, menuNum);     /* Unhighlight the menu title. */
  76. }
  77.  
  78. /**********************************************************************/
  79.  
  80. void    setupMenus()
  81. {
  82.     /* Procedure to install our menu titles and their items in the system menu
  83.     ** bar and to redraw it so we can see them.
  84.     */
  85.  
  86.     SetSysBar(NewMenuBar2(refIsResource, 0x1000L, NULL));
  87.     SetMenuBar(NULL);
  88.     
  89.     FixAppleMenu(AppleMenuID);                /* Add DAs to apple menu     */
  90.     FixMenuBar();                            /* Set sizes of menus         */
  91.     DrawMenuBar();                            /* ...and draw the menu bar! */
  92. }
  93.